package com.perfma.xtest.tool.word;

import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;


/**
 * @author tongtingjian
 * @version v1.0 2018年09月01日 下午3:32
 **/
@Data
@NoArgsConstructor
@ApiModel("告警规则")
public class AlertRule {

    private Long id;

    private Long merchantId;

    private String name;

    private String sceneName;

    private Long goalId;

    private Long sceneId;

    private String quota;

    private boolean percentage;

    private Double thresholdUp;

    private Double /**/thresholdDown;

    private Double floatRateUp;

    private Double floatRateDown;

    private Double floatOffset;

    private Double baselineValue;

    private String quotaType;

    private String quotaTypeName;//事务/应用

    private Integer targetType;

    private Long targetId;

    private String targetName;

    private MonEntityType type;// 根据【quotaType】字段，返回时填充

    private String unit;// 指标单位，返回时填充

    private String require;//要求：大于等于、小于

    public void setTargetName(String targetName) {
        if (StringUtils.isNotBlank(targetName) && targetName.length() > 254) {
            targetName = targetName.substring(0, 253);
        }

        this.targetName = targetName;
    }

    private String description;

    @Builder
    public AlertRule(Long id, Long merchantId, String name, Long sceneId, Long goalId, String quota,  boolean percentage, Double thresholdUp, Double thresholdDown, Double floatRateUp, Double floatRateDown, Double floatOffset, Double baselineValue, String quotaType, Integer targetType, Long targetId, String targetName, String description) {
        this.id = id;
        this.merchantId = merchantId;
        this.name = name;
        this.goalId = goalId;
        this.sceneId = sceneId;
        this.quota = quota;
        this.percentage = percentage;
        this.thresholdUp = thresholdUp;
        this.thresholdDown = thresholdDown;
        this.floatRateUp = floatRateUp;
        this.floatRateDown = floatRateDown;
        this.floatOffset = floatOffset;
        this.baselineValue = baselineValue;
        this.quotaType = quotaType;
        this.targetType = targetType;
        this.targetId = targetId;
        this.targetName = targetName;
        this.description = description;
    }
}
